import java.util.Arrays;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/6/27 21:44
 */

public class Solution {
    public String largestNumber(int[] nums) {
        int n = nums.length;
        String[] strs = new String[n];

        // 将数字转换为字符串并存储到字符串数组中
        for (int i = 0; i < n; i++) {
            strs[i] = "" + nums[i];
        }

        // 对字符串数组进行排序，排序规则为：将两个字符串拼接后比较大小
        Arrays.sort(strs, (a, b) -> {
            return (b + a).compareTo(a + b);
        });

        StringBuffer ret = new StringBuffer();
        for (String s : strs) {
            ret.append(s);
        }

        // 如果排序后的第一个字符为'0'，则说明所有数字都为0
        if (ret.charAt(0) == '0') {
            return "0";
        }

        return ret.toString();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.largestNumber(nums));
        }
    }
}